<?php
/**
 * Charge Controller for Congregation Component
 * 
 * @package    Congregation
 * @subpackage Components
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_4
 * @license		GNU/GPL
 */

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

/**
 * Charge Controller
 *
 * @package    Congregation
 * @subpackage Components
 */
class AquoteControllerQuote extends AquoteController
{
	/**
	 * constructor (registers additional tasks to methods)
	 * @return void
	 */
	function __construct()
	{
		$this->db =& JFactory::getDBO();

		parent::__construct();
	}
	
	function daily()
	{
		$lg = &JFactory::getLanguage();
		$language = $lg->get('tag');
		$qlang = strtoupper(substr($language, 0,2));
		$qdate = date("m") . "/" . date("d");
		
		$query = "SELECT * FROM #__aquote_quotes WHERE qlang='{$qlang}' AND qdate='{$qdate}' ORDER BY RAND() LIMIT 1";
		
		$document =& JFactory::getDocument();
		$document->setMimeEncoding( 'text/xml' );

		
		$this->db->setQuery($query);
		
		$item = $this->db->loadObject();
		echo '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
		echo "<quote><text>" . htmlspecialchars($item->qtext) . "</text><source>" . htmlspecialchars($item->qsource) . "</source><language>" . $item->qlang . "</language><date>" . $item->qdate . "</date></quote>";
		
	}
	
	
}